<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>留学生管理系统</title>  
        <link rel="stylesheet" href="${path}/css/admin2.css">
        <style>
          #visa-modal{
                margin: 15% auto;
                padding: 10px;
                width: 400px;
            }
             #visa-modal2{
                margin: -15% auto;
                padding: 10px;
                width: 400px;
            }
             #newVisa{
                margin: 15% auto;
                padding: 10px;
                width: 400px;
            }
            #addStu{
            width:300px;
            word-wrap: break-word;
            }
            #select{
            position:absolute;
    			z-index: 2000;
    			margin:-15% 0 0 0;
    			left:50%;
    			transform: translateX(-50%);
            }
            .student{
   				
    			
    			padding: 10px 30px 30px;
    			width: 900px;
    			min-height: 500px;
    			background: #fff;
			}
			th a{
			text-decoration: underline;
            color: #007CBC;
			}
        </style>
        <script>
            var _current_item = "#adminVisaManage";          
        </script>
        <script type="text/javascript" src="${path}/js/jquery.min.js"></script>
    </head>
    <body>
        <!--header-->
        <div id="above-mask">
            <div class="fileupload pannel hide" id="fileupload-pannel">
                <div class="close-container">
                    <a class="close" onclick="hide('#above-mask, #mask, #fileupload-pannel');">×</a>
                </div>
                <form action="${path}/adminVisaManage/stuVisaUpload" method="post" enctype="multipart/form-data" name="fileForm">
                    <div style="margin-top: 30px;"> 上传文件：（支持Excel 97-2003 工作簿 .xls格式文件）</div>
                    <input id="fileCover" class="left" readonly="readonly" placeholder="导入excel文件" type="text" style="width: 280px; height: 22px;">
                    <button onclick="$('#uploadFile').click();return false;" style="background: #aaa">浏览文件</button>
                    <input type="file" name="uploadFile" required="required" id="uploadFile" style="display:none" onchange="$('#fileCover').val($(this).val());">
                    <div>
                        <button type="submit" style="display: block; margin: 0 auto;">提交</button> 
                    </div>
                </form>
            </div>
            <div class="pannel hide" id="visa-modal">
                <div class="close-container">
                    <a class="close" onclick="hide('#mask, #above-mask, #visa-modal')">&times;</a>
                </div>
                <div>请选择签证有效期：</div><br /><br />
				<div style="padding-left:80px;padding-bottom:40px">
				<label class="radio-inline"> <input type="radio"
					name="visaTime" id="inlineRadio1" value="1" checked>
					6个月
				</label> <label class="radio-inline"> <input type="radio"
					name="visaTime" id="inlineRadio2" value="2">
					1年
				</label> <label class="radio-inline"> <input type="radio"
					name="visaTime" id="inlineRadio3" value="3">
					期限离境
				</label>
				</div>
				<button style="margin-left:250px;" passNo="" id="passNo" onclick="ajaxVisa();">确定</button>
			 </div>
			<!--  新建签证 -->
			<div class="pannel hide" id="newVisa">
                <div class="close-container">
                    <a class="close" onclick="$('#select').html('');hide('#mask, #above-mask, #newVisa,#visa-modal2');">&times;</a>
                </div>
                <form action="${path}/adminVisaManage/printVisa" method="post" id="printForm">
                <div>请选择新建签证学生及时长：</div><br />
                <table>
                <tr><th style="width:100px"><a onclick="createDatatable('#select .stu_1');show('#select .student');makeStringToDictS(this.parentNode.parentNode.lastChild.firstChild.innerHTML,this.parentNode.parentNode.lastChild.firstChild.innerHTML);"><b>学生:</b></a></th><td style="width:300px"><div id="addStu"></div><input type="hidden" id="stuPassportNo" name="passportNo"></td></tr>
                <tr><th><a  onclick="show('#mask, #above-mask, #visa-modal2')"><b>签证时长:</b></a></th><td><div id="addVisaTime" name="addVisaTime"></div><input type="hidden" id="time" name="time"></td></tr>
                </table>
                <div id="select"></div>
                
				<button style="margin-left:0;width:100%" id="add_print" type="button" onclick="printStu();">打印</button>
				</form>
			 </div>
			 <!-- 签证时长 -->
			 <div class="pannel hide" id="visa-modal2">
                <div class="close-container">
                    <a class="close" onclick="hide('#visa-modal2')">&times;</a>
                </div>
                <div>请选择签证有效期：</div><br /><br />
				<div style="padding-left:80px;padding-bottom:40px">
				<label class="radio-inline"> <input type="radio"
					name="visaTime2" id="time1" value="1" checked>
					六个月
				</label> <label class="radio-inline"> <input type="radio"
					name="visaTime2" id="time2" value="2">
					一年
				</label> <label class="radio-inline"> <input type="radio"
					name="visaTime2" id="time3" value="3">
					期限离境
				</label>
				</div>
				<button style="margin-left:250px;" passNo="" id="addTime" onclick="addTime();">确定</button>
			 </div>
			<!--  /新建签证 -->
        </div>
         <!--student-->
            <div id="student" class="student hide pannel">
                        <div class="close-container"><a class="close" onclick="hide('#student')"></a></div><br>
                        <div class="modal-body">
                            <span>专业</span>
                            <select onchange="lookStudent();" id="majorNo">
                                <option>全部</option>
                                <#if allMajorName?exists>
                                <#list allMajorName as r> 
                                <option value="${r.majorNo!}">${r.majorName!}</option>
                                </#list>
                                </#if>
                            </select>
                            <span>入学年份</span>
                            <select onchange="lookStudent();" id="startDate">
                                <option>全部</option>
                                <option>2013</option>
                                <option>2014</option>
                                <option>2015</option>
                                <option>2016</option>
                            </select>

                            <table class="stu_1" id="stu_1">
                                <thead>
                                    <tr>
                                        <td><input type="checkbox" id="checkstudent" onchange="checkAll(this,'#stu_1')"></td> 
                                        <td>学号</td>
                                        <td>护照号</td>
                                        <td>名</td>
                                        <td>姓</td>
                                        <td>专业</td> 
                                        <td>入学年份</td>
                                    </tr>
                                </thead>
                                <tbody>
                                    <#if stuInfo?exists>
                                    <#list stuInfo as r>
                                    <tr>
                                        <td><input type="checkbox" value="${r.passportNo}" newPpn="${r.sNo}" id="studentCheck${r_index}"  onchange="alterStu(this);"></td>
                                        <td>${r.sNo!}</td>
                                        <td>${r.newpassportNo!}</td>
                                        <td>${r.firstName!}</td>
                                        <td>${r.lastName!}</td>
                                        <td>${r.majorName!}</td>
                                        <td>${r.eduStartDate!}</td>
                                    </tr>
                                    </#list>
                                    </#if>
                                </tbody>
                            </table>
                            <button  type="button" onclick="fromDictToString('#addStu','#stuPassportNo');hide('#student');">确定</button>
                        </div>
            </div>
            <!--student end-->
        <div id="mask"></div>
        <div id="header"></div>
        <div id="main">
            <div id="side-menu"></div>
            <div id="container">
                <div id="inner-border">
                    <div>
                        <label>专业</label>
                        <select id="pay_major" name="pay_major">
                            <option value="0">全部</option>
                             <#if allMajorName??>
                                <#list allMajorName as ts>
                           		 <option value="${ts.majorNo}">&nbsp;${ts.majorName}</option>
                          	  </#list>
                                </#if>
                        </select>
                     <label>入学年份</label>
                        <select id="pay_year" name="pay_year">
                            <option value="0">全部</option>
                           		<#if allEduStartDate??>
                                <#list allEduStartDate as ts>
                                <option value="${ts.eduStartDate}">&nbsp;${ts.eduStartDate}</option>
                                </#list>
                                </#if>
                        </select> 
                    	<label>入学季度</label>
                        <select id="pay_quar" name="pay_quar">
                            <option value="0">全部</option>
                             <#if allEduSeason??>
                                <#list allEduSeason as ts>
                                <option value="${ts.eduSeason}">&nbsp;${ts.eduSeason}</option>
                                </#list>
                                </#if>
                        </select>  
                        <button type="button" onclick="ajaxsearch()">筛选</button>
                        <button onclick="show('#mask, #above-mask, #fileupload-pannel')">批量导入</button>
                    	<button onclick="window.location.href = '${path}/adminVisaManage/fileDownload'">模板下载</button>
                    	<button style="background-color:#5CB85C"type="button" onclick="show('#mask, #above-mask,#newVisa');newStu();">新建签证</button>
                    </div>
                    <form action="${path}/adminteamanage/batch" method="post" name="myForm">
                        <input type="hidden" name="checkboxValue" id="checkboxValue">
                        <div id="error" style="display:none">${error!}</div>  
                        <input type="hidden" name="action" value="re"> 
                        <table class="table table-bordered" id="ttable">
                            <thead>
                                <tr>
                               		<th>学号</th>
                                    <th>护照号</th>
                                    <th>姓</th>
                                    <th>名</th>
                                    <th>专业</th>
                                    <th>签证时间段</th>
                                    <th>签证时长</th>
                                    <th>签证类型</th>
                                   <!--  <th>操作</th> -->
                                </tr>
                            </thead>
                            <tbody>
                            <#if stuVisa??>
                            <#list stuVisa as visa>
                                <tr>
                               <td>${visa.sNo!}</td>
                               <td name="passportNo">${visa.newpassportNo!}</td>
                               <td>${visa.lastName!}</td>
                               <td>${visa.firstName!}</td>
                               <td>${visa.majorName!}</td>
                               <td>${visa.visaDate!}</td>
                               <td>${visa.visaTime!}</td>
                               <td>${visa.visaType!}</td>
                               <!-- <td><button class="edit" style="background-color:#5CB85C"type="button" passportno="${visa.passportNo!}"onclick="show('#mask, #above-mask,#visa-modal');print(this)">打印</button>
                                </td> -->
                                </tr>
                                </#list>
                                </#if>
                            </tbody>
                        </table>
                        </form>
                </div>
            </div>
        </div>
        <div id="footer"></div>
        <script type="text/javascript" src="${path}/js/admin-main-appearance.js"></script>
        <script src="${path}/js/amazeui.min.js"></script>
        

        <!-- DataTables JavaScript -->
        <script src="${path}/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetHiddenNodes.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetTd.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetTds.js"></script>
        <script src="${path}/bower_components/datatables-plugins/api/fnGetColumnData.js"></script>
        <script src="${path}/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>
        <script src="${path}/js/linkPage.js"></script>
        <script type="text/javascript" src="${path}/js/My97DatePicker/WdatePicker.js"></script>

        <script type="text/javascript">
            $(document).ready(function () {
                $('#ttable').DataTable({
                    responsive: true,
                    ordering: false,
                    searching: true,
                    "bLengthChange": false,
                    "bRetrieve": true,
                    "bFilter": true//过滤功能
                });
                
                 if("${visaInfRet!}"!=""){
                      alert("${visaInfRet!}");
                      }
                
            });
        </script>  
        <script type="text/javascript">
           function print(node){
           
          
           var tr=node.parentNode.parentNode;
          var passNo = node.getAttribute("passportno");
           var newpassNo = tr.cells[0].innerText;
           var stuName=tr.cells[1].innerText+"  "+tr.cells[2].innerText;
           //alert(stuName);
           $("#passNo").attr("passNo",passNo);
           $("#passNo").attr("stuName",stuName);
           $("#passNo").attr("newpassNo",newpassNo);
           
                           
           }
            
            function getRadioValue(radioName) {        
	 			var chkRadio = document.getElementsByName(radioName);        
	 			for (var i = 0; i < chkRadio.length; i++) {          
	 			if (chkRadio[i].checked)            
				return chkRadio[i].value;        
				}      
	 		}
	 
	 	function ajaxVisa(){
	 	var visa = getRadioValue("visaTime");
	 	var passNo = $("#passNo").attr("passNo"); 
	 	var stuName = $("#passNo").attr("stuName"); 
	 	var newpassNo = $("#passNo").attr("newpassNo");
	 	setCookie("visa",visa);
	 	setCookie("stuName",stuName);
	 	setCookie("passNo",passNo);
	 	setCookie("newpassNo",newpassNo);
	 	
	 	
	 	$.ajax({
                    type:"post",
                    url:'${path}/adminVisaManage/stuVisaPrint',
                    dataType: "json",
                    data:{
                    		visaTime:visa,
                    		passportNo:passNo,
                    },
                    datatype:"json",
                    success:function(data){
                       window.location.href="${path}/adminVisaManage/stuVisaHtml";
         
                    }
                });

	 	}
            
            function ajaxsearch(){
            $.ajax({
            type:"get",
                    url:'${path}/adminVisaManage/printSerch',
                    data:{
                            majorNo:$('#pay_major').val(),
                            eduStartDate:$('#pay_year').val(),
                            eduSeason:$('#pay_quar').val(),
                    },
                    datatype:"json",
                    success:function(data){
                   //alert("success");
                   //alert(data);
                    alert(JSON.stringify(data));
                     $('#ttable').dataTable().fnClearTable();
                     $.each(data,function(num,data){
                    	 $('#ttable').dataTable().fnAddData([data.sNo,data.newpassportNo,data.lastName,data.firstName,data.majorName,data.visaDate,data.visaTime,data.visaType,'<button class="edit" style="background-color:#5CB85C"type="button" class="edit" passportno="'+data.passportNo+'"onclick="show(\'#mask, #above-mask,#visa-modal\');print(this)">打印</button>']);
               
                     })
                
                   // getdata(data);
                    } 
            });
            }
            
            //新建签证时长
            function addTime(){
            	var time = getRadioValue("visaTime2");
            	if(time=="1"){
            		$("#addVisaTime").html("六个月");
            		
            	}else if(time=="2"){
            		$("#addVisaTime").html("一年");
            		
            	}else{
            		$("#addVisaTime").html("期限离境");
            		
            	}
            	$("#addVisaTime").attr("time",time);
            	$("#time").val(time);
            	hide("#visa-modal2");
            
            }
            
            //打印按钮
            /* $("#add_print").on("click",function(){
            var time = $("#addVisaTime").attr("time");
            var passportNo = $("#stuPassportNo").val();
            alert(passportNo);
            $("#select").html("");
            hide("#mask, #above-mask, #newVisa,#visa-modal2");
            
		     $.ajax({
		        async: false,
		    	type: "POST",
		        url: "${path}/adminVisaManage/addVisa",
		    	dataType: "json",
		        data: {
		        time:time,
		        passportNo:passportNo,
		          },
		        success: function (data) {
		        alert("yes");
		        location.reload();
		        },
		        error: function (err) {
		        alert("no");
		        location.reload();
		          },
		     });
            }) */
            
            					function lookStudent() {

		                                    var startDate = document.getElementById("startDate").value;
		                                    var majorNo = document.getElementById("majorNo").value;
		
		                                    $.ajax({
		                                        async: false,
		                                        type: "POST",
		                                        url: "${path}/adminCourseManage/lookStudent",
		                                        dataType: "json",
		                                        data: {
		                                            startDate: startDate,
		                                            majorNo: majorNo,
		                                        },
		                                        success: function (data) {
		                                        //alert(JSON.stringify(data));
		                                            $('#stu_1').dataTable().fnClearTable();
		                                            for (var i = 0; i < data.length; i++) {
		                                                $('#stu_1').dataTable().fnAddData(['<input id="studentCheck0" newPpn="' + data[i]["sNo"]+'"type="checkbox" value="' + data[i]["passportNo"] + '" name="studentCheck" onclick="alterStu(this);">', data[i]["sNo"], data[i]["newpassportNo"], data[i]["firstName"], data[i]["lastName"], data[i]["majorName"], data[i]["eduStartDate"]]);
		                                                var ot = $('#stu_1').dataTable();
		                                            }
		                                            checkChecked('#stu_1');
		                                        },
		                                        error: function (err) {
		                                            alert("获取该专业入学年份的学生失败");
		                                        },
		                                    });
		                                }
		      
		      function printStu(){
		      	if($("#addStu").html()==""){
		      		alert("请选择学生");
		      		return false;
		      	}
		      	if($("#addVisaTime").html()==""){
		      	alert("请选择时长");
		      	return false;
		      	}
		      	$("#printForm").submit();
		  	    hide('#mask, #above-mask, #newVisa,#visa-modal2');
		      }
		         
		                                
        </script>
        <script type="text/javascript">
            $(document).ready(function () {
                if ($("#error").html() != "") {
                    Alert($("#error").html());
                }
                //alert($("#error").html());}
            });
        </script> 
        <script>
            //自动关闭提示框  
            function Alert(str) {
                alert(str);
            }
        </script>
    </body>
</html>
